<template>
  <div>
    <h2>我是About</h2>
  </div>
</template>

<script>
export default {
  name: "About",
  // 销毁生命周期勾子
  // beforeDestroy() {
  //   console.log("About即将被销毁")
  // },
  // mounted() {
  //   console.log("About组件挂载完毕", this)
  //   window.aboutRoute = this.$route
  //   window.aboutRouter = this.$router
  // },
  mounted() {
    console.log("%%", this.$route)
  },
  // 通过路由规则，进入该组件时被调用
  beforeRouteEnter(to, from, next) {
    // 组件内部路由守卫
    console.log("About---beforeRouteEnter", to, from)
    //判断是否需要鉴权
    if (to.meta.isAuth) {
      if (localStorage.getItem("school") === "qinghua") {
        next();
      } else {
        alert("无权限查看！");
      }
    } else {
      next();
    }
  },
  // 通过路由规则，离开该组件时被调用
  beforeRouteLeave(to, from, next) {
    // 组件内部路由守卫
    console.log("About---beforeRouteLeave", to, from)
    next()
  }
}
</script>

<style lang="scss" scoped></style>